library(googlesheets4)
library(sf)
library(sfheaders)
library(tidyverse)
library(southernMaps)
library(mapview)
library(terra)
library(tidyterra)
library(rcartocolor)
library(ggnewscale)
library(ggspatial)
library(kableExtra)
library(ggrepel)
theme_set(theme_bw())Plan for Fiordland BRUV FLD25
Setup
Load NZ coastline data
… and convert to sf object.
nztm <- detailed_nz_islands |> st_as_sf()Marine reserves data
load(file = "data/mr_fiordland.Rdata")Load strata
strata <- st_read("data/FLD25_Strata.kml")Reading layer `Strata' from data source
`C:\git_projects\fiordland_bruv\data\FLD25_Strata.kml' using driver `KML'
Simple feature collection with 13 features and 2 fields
Geometry type: POLYGON
Dimension: XYZ
Bounding box: xmin: 166.3883 ymin: -45.8432 xmax: 167.0177 ymax: -45.47082
z_range: zmin: 0 zmax: 0
Geodetic CRS: WGS 84
plot(strata)Load mark
mark <- png::readPNG("img/mark_blank.png") |> grid::rasterGrob(interpolate=TRUE)BRUV data
Load from Google Sheet
… and convert to sf object.
fld24 <- read_sheet(
"https://docs.google.com/spreadsheets/d/1IQfLTiWTQnTGynuF7fUu8htJxKZuIVJw4OK6y9qRfU8",
sheet="FLD24") |>
mutate(Depth = coalesce(`Depth sensor`,`Depth sounder`)) |>
st_as_sf(coords = c('Longitude','Latitude'), crs=4326) |>
st_join(strata["Name"]) |>
filter(Quality %in% c("Good", "OK"))Write full dataset to csv file (for copying stratum column into BRUVmetadata – actually nah)
read_sheet(
"https://docs.google.com/spreadsheets/d/1IQfLTiWTQnTGynuF7fUu8htJxKZuIVJw4OK6y9qRfU8",
sheet="FLD24") |>
mutate(Depth = coalesce(`Depth sensor`,`Depth sounder`)) |>
st_as_sf(coords = c('Longitude','Latitude'), crs=4326) |>
st_join(strata["Name"]) |>
write_csv(file = "data/fld24_strata.csv")✔ Reading from "BRUVmetadata".
✔ Range ''FLD24''.
st_as_s2(): dropping Z and/or M coordinate
Export data for printing
dstrat <- c("DZ1","DZ2","DR2","DZ3","DZ4" )decimal_to_dm <- function(decimal_degrees) {
require(measurements)
conv_unit(decimal_degrees, from = "dec_deg", to = "deg_dec_min")
}fld24_toprint <- fld24 |>
filter(Quality != "BAD") |>
as_data_frame() |>
transmute(
SiteID,
SetRep = substring(OpCode, 7, 13),
Loc = Location,
Stratum = Name |>
fct_relevel(dstrat),
Depth,
lat = st_coordinates(fld24)[,2] |> round(5),
lon = st_coordinates(fld24)[,1] |> round(5),
lat2 = st_coordinates(fld24)[,2] |> decimal_to_dm(),
lon2 = st_coordinates(fld24)[,1] |> decimal_to_dm()
) |>
arrange(Stratum)Warning: `as_data_frame()` was deprecated in tibble 2.0.0.
ℹ Please use `as_tibble()` (with slightly different semantics) to convert to a
tibble, or `as.data.frame()` to convert to a data frame.
Loading required package: measurements
kable(fld24_toprint)| SiteID | SetRep | Loc | Stratum | Depth | lat | lon | lat2 | lon2 |
|---|---|---|---|---|---|---|---|---|
| LC01 | S02_R01 | Luncheon Cove | DZ1 | 35.9 | -45.77672 | 166.4945 | -45 46.6030000000018 | 166 29.6699999999992 |
| LC02 | S02_R02 | Luncheon Cove | DZ1 | 23.0 | -45.77042 | 166.4982 | -45 46.2250000000019 | 166 29.89099999998 |
| LC03 | S02_R03 | Luncheon Cove | DZ1 | 34.0 | -45.77522 | 166.5058 | -45 46.5130000000019 | 166 30.3450000000012 |
| LC08 | S02_R05 | Luncheon Cove | DZ1 | 40.0 | -45.76553 | 166.5292 | -45 45.9319999999983 | 166 31.7509999999796 |
| LC06 | S02_R06 | Luncheon Cove | DZ1 | 42.0 | -45.77145 | 166.5326 | -45 46.287 | 166 31.9549999999814 |
| AI08 | S03_R02 | Anchor Island | DZ1 | 21.0 | -45.73870 | 166.5252 | -45 44.3220000000001 | 166 31.5139999999801 |
| AI09 | S03_R03 | Anchor Island | DZ1 | 38.0 | -45.74827 | 166.5181 | -45 44.8960000000021 | 166 31.08400000002 |
| AI10 | S03_R04 | Anchor Island | DZ1 | 28.0 | -45.74457 | 166.5100 | -45 44.674000000002 | 166 30.5989999999797 |
| AI11 | S03_R05 | Anchor Island | DZ1 | 71.0 | -45.74618 | 166.5016 | -45 44.7709999999977 | 166 30.0940000000196 |
| AI12 | S03_R06 | Anchor Island | DZ1 | 71.0 | -45.75023 | 166.5000 | -45 45.013999999998 | 166 30.0029999999989 |
| AI01 | S04_R01 | Anchor Island | DZ1 | 41.8 | -45.75005 | 166.5258 | -45 45.0029999999999 | 166 31.5490000000204 |
| AI02 | S04_R02 | Anchor Island | DZ1 | 79.0 | -45.74478 | 166.5167 | -45 44.6869999999981 | 166 31.0000000000194 |
| AI03 | S04_R03 | Anchor Island | DZ1 | 20.0 | -45.74017 | 166.5253 | -45 44.410000000002 | 166 31.5179999999993 |
| LC04 | S05_R04 | Luncheon Cove | DZ1 | 86.0 | -45.77767 | 166.5152 | -45 46.660000000002 | 166 30.910000000019 |
| LC05 | S05_R05 | Luncheon Cove | DZ1 | 45.0 | -45.77575 | 166.5234 | -45 46.5450000000002 | 166 31.4059999999804 |
| LC07 | S05_R06 | Luncheon Cove | DZ1 | 30.0 | -45.76930 | 166.5201 | -45 46.1580000000002 | 166 31.2060000000017 |
| OF01 | S22_R01 | Outer Five Fingers | DZ1 | 34.0 | -45.71893 | 166.4898 | -45 43.1359999999976 | 166 29.3909999999994 |
| OF02 | S22_R02 | Outer Five Fingers | DZ1 | 44.0 | -45.72385 | 166.4839 | -45 43.4309999999998 | 166 29.035000000019 |
| OF03 | S22_R03 | Outer Five Fingers | DZ1 | 25.0 | -45.72788 | 166.4762 | -45 43.6729999999981 | 166 28.5730000000195 |
| OF04 | S22_R04 | Outer Five Fingers | DZ1 | 34.0 | -45.73192 | 166.4712 | -45 43.9150000000018 | 166 28.275 |
| OF05 | S22_R05 | Outer Five Fingers | DZ1 | 17.0 | -45.73392 | 166.4650 | -45 44.035000000002 | 166 27.9019999999805 |
| OF06 | S22_R06 | Outer Five Fingers | DZ1 | 31.0 | -45.73877 | 166.4598 | -45 44.3260000000019 | 166 27.5860000000199 |
| EA02 | S01_R02 | East Anchor | DZ2 | 23.0 | -45.76108 | 166.5369 | -45 45.664999999998 | 166 32.2120000000209 |
| EA03 | S01_R03 | East Anchor | DZ2 | 79.0 | -45.75900 | 166.5446 | -45 45.5399999999999 | 166 32.6770000000193 |
| EA08 | S01_R04 | East Anchor | DZ2 | 17.0 | -45.77003 | 166.5534 | -45 46.201999999998 | 166 33.2070000000007 |
| EA05 | S01_R05 | East Anchor | DZ2 | 65.0 | -45.76277 | 166.5631 | -45 45.7660000000018 | 166 33.7879999999811 |
| EA06 | S01_R06 | East Anchor | DZ2 | 86.0 | -45.76553 | 166.5525 | -45 45.9319999999983 | 166 33.1510000000203 |
| AI07 | S03_R01 | Anchor Island | DZ2 | 49.1 | -45.73245 | 166.5272 | -45 43.9470000000001 | 166 31.6309999999804 |
| AI04 | S04_R04 | Anchor Island | DZ2 | 83.0 | -45.73032 | 166.5401 | -45 43.8190000000022 | 166 32.4070000000201 |
| AI05 | S04_R05 | Anchor Island | DZ2 | 54.0 | -45.74125 | 166.5464 | -45 44.475 | 166 32.7859999999792 |
| AI06 | S04_R06 | Anchor Island | DZ2 | 29.0 | -45.74172 | 166.5556 | -45 44.5030000000018 | 166 33.3329999999997 |
| EA01 | S05_R01 | East Anchor | DZ2 | 57.0 | -45.76440 | 166.5409 | -45 45.8639999999999 | 166 32.4550000000202 |
| EA04 | S05_R02 | East Anchor | DZ2 | 30.0 | -45.75715 | 166.5584 | -45 45.4290000000003 | 166 33.5050000000202 |
| EA07 | S05_R03 | East Anchor | DZ2 | 38.0 | -45.75388 | 166.5717 | -45 45.2329999999978 | 166 34.3039999999785 |
| RI01 | S08_R01 | Resolution Island | DZ2 | 19.2 | -45.72102 | 166.5831 | -45 43.261000000002 | 166 34.9870000000189 |
| RI02 | S08_R02 | Resolution Island | DZ2 | 34.0 | -45.71980 | 166.5733 | -45 43.188 | 166 34.3960000000196 |
| PP02 | S08_R05 | Pigeon & Parrot Islands | DZ2 | 40.0 | -45.71513 | 166.5280 | -45 42.9079999999977 | 166 31.6810000000211 |
| PP03 | S08_R06 | Pigeon & Parrot Islands | DZ2 | 32.0 | -45.72005 | 166.5267 | -45 43.2029999999999 | 166 31.6049999999988 |
| LI03 | S17_R03 | Long Island | DZ2 | 23.0 | -45.77240 | 166.6003 | -45 46.3439999999997 | 166 36.0160000000207 |
| LI04 | S17_R04 | Long Island | DZ2 | 25.0 | -45.77600 | 166.6013 | -45 46.5600000000001 | 166 36.0760000000184 |
| PH01 | S19_R01 | Pickersgill Harbour | DZ2 | 31.5 | -45.79447 | 166.5908 | -45 47.6680000000022 | 166 35.4450000000012 |
| PH02 | S19_R02 | Pickersgill Harbour | DZ2 | 33.0 | -45.79415 | 166.5842 | -45 47.649 | 166 35.0509999999796 |
| PH03 | S19_R03 | Pickersgill Harbour | DZ2 | 42.0 | -45.79445 | 166.5934 | -45 47.6669999999998 | 166 35.6020000000213 |
| PH04 | S19_R04 | Pickersgill Harbour | DZ2 | 32.0 | -45.78363 | 166.5830 | -45 47.0179999999978 | 166 34.9810000000192 |
| PH05 | S19_R05 | Pickersgill Harbour | DZ2 | 81.0 | -45.78190 | 166.6001 | -45 46.9139999999999 | 166 36.0049999999794 |
| ES01 | S21_R01 | Earshell Cove | DZ2 | 31.2 | -45.72475 | 166.5894 | -45 43.4850000000001 | 166 35.36599999998 |
| ES02 | S21_R02 | Earshell Cove | DZ2 | 48.0 | -45.72678 | 166.5842 | -45 43.6069999999983 | 166 35.0550000000008 |
| ES03 | S21_R03 | Earshell Cove | DZ2 | 21.0 | -45.73117 | 166.5777 | -45 43.8700000000021 | 166 34.6609999999792 |
| ES04 | S21_R04 | Earshell Cove | DZ2 | 46.0 | -45.73853 | 166.5701 | -45 44.3119999999981 | 166 34.2040000000192 |
| ES05 | S21_R05 | Earshell Cove | DZ2 | 60.0 | -45.74320 | 166.5735 | -45 44.5920000000003 | 166 34.4119999999801 |
| ES06 | S21_R06 | Earshell Cove | DZ2 | 52.7 | -45.74770 | 166.5760 | -45 44.862 | 166 34.5580000000191 |
| FH01 | S23_R01 | Fixed Head | DZ2 | 25.0 | -45.76270 | 166.5871 | -45 45.762 | 166 35.2240000000204 |
| FH02 | S23_R02 | Fixed Head | DZ2 | 45.0 | -45.75477 | 166.6083 | -45 45.286000000002 | 166 36.4969999999797 |
| FH03 | S23_R03 | Fixed Head | DZ2 | 18.0 | -45.74933 | 166.6143 | -45 44.9599999999977 | 166 36.8599999999802 |
| FF01 | S06_R01 | Five Fingers | DR2 | 31.1 | -45.70582 | 166.5711 | -45 42.349000000002 | 166 34.2630000000005 |
| FF02 | S06_R02 | Five Fingers | DR2 | 52.0 | -45.70425 | 166.5616 | -45 42.2550000000003 | 166 33.6970000000205 |
| FF03 | S06_R03 | Five Fingers | DR2 | 63.0 | -45.70360 | 166.5512 | -45 42.2159999999999 | 166 33.0700000000206 |
| FF04 | S06_R04 | Five Fingers | DR2 | 86.0 | -45.70063 | 166.5412 | -45 42.037999999998 | 166 32.4709999999808 |
| FF05 | S06_R05 | Five Fingers | DR2 | 25.0 | -45.69333 | 166.5438 | -45 41.5999999999981 | 166 32.6280000000009 |
| FF06 | S06_R06 | Five Fingers | DR2 | 18.0 | -45.69175 | 166.5565 | -45 41.5049999999998 | 166 33.391999999979 |
| FF07 | S07_R01 | Five Fingers | DR2 | 28.5 | -45.68888 | 166.5305 | -45 41.3329999999982 | 166 31.8310000000211 |
| FF08 | S07_R02 | Five Fingers | DR2 | 28.0 | -45.69353 | 166.5240 | -45 41.6119999999981 | 166 31.4370000000015 |
| FF09 | S07_R03 | Five Fingers | DR2 | 27.0 | -45.69867 | 166.5181 | -45 41.9200000000021 | 166 31.0870000000189 |
| FF10 | S07_R04 | Five Fingers | DR2 | 26.0 | -45.70330 | 166.5104 | -45 42.1980000000001 | 166 30.6269999999999 |
| FF11 | S07_R05 | Five Fingers | DR2 | 18.0 | -45.70938 | 166.5012 | -45 42.562999999998 | 166 30.0720000000011 |
| FF12 | S07_R06 | Five Fingers | DR2 | 41.0 | -45.71433 | 166.4979 | -45 42.8599999999982 | 166 29.8720000000205 |
| RI03 | S08_R03 | Resolution Island | DR2 | 25.0 | -45.71353 | 166.5591 | -45 42.8119999999981 | 166 33.5449999999798 |
| PP01 | S08_R04 | Pigeon & Parrot Islands | DR2 | 39.0 | -45.70965 | 166.5481 | -45 42.5790000000003 | 166 32.8870000000209 |
| SI05 | S09_R05 | Shag Island | DZ3 | 35.0 | -45.74290 | 166.7680 | -45 44.574 | 166 46.0800000000008 |
| SI06 | S09_R06 | Shag Island | DZ3 | 28.0 | -45.74382 | 166.7570 | -45 44.6290000000023 | 166 45.4180000000206 |
| SI11 | S15_R05 | Shag Island | DZ3 | 64.0 | -45.74245 | 166.7635 | -45 44.5470000000001 | 166 45.8070000000007 |
| SI12 | S15_R06 | Shag Island | DZ3 | 45.0 | -45.74392 | 166.7555 | -45 44.635000000002 | 166 45.3310000000211 |
| II01 | S16_R01 | Indian Island | DZ3 | 28.0 | -45.76110 | 166.6465 | -45 45.6659999999999 | 166 38.7880000000199 |
| II02 | S16_R02 | Indian Island | DZ3 | 57.0 | -45.76187 | 166.6405 | -45 45.712000000002 | 166 38.4329999999997 |
| II03 | S16_R03 | Indian Island | DZ3 | 36.0 | -45.76823 | 166.6378 | -45 46.0939999999978 | 166 38.2709999999982 |
| II04 | S16_R04 | Indian Island | DZ3 | 46.0 | -45.76727 | 166.6315 | -45 46.036000000002 | 166 37.8899999999984 |
| II05 | S16_R05 | Indian Island | DZ3 | 28.0 | -45.77097 | 166.6236 | -45 46.2580000000021 | 166 37.4170000000197 |
| II06 | S16_R06 | Indian Island | DZ3 | 47.0 | -45.76517 | 166.6241 | -45 45.910000000002 | 166 37.4479999999787 |
| LI01 | S17_R01 | Long Island | DZ3 | 14.2 | -45.76587 | 166.6148 | -45 45.9520000000024 | 166 36.8909999999994 |
| LI02 | S17_R02 | Long Island | DZ3 | 30.0 | -45.77093 | 166.6104 | -45 46.2559999999983 | 166 36.6269999999999 |
| LI05 | S17_R05 | Long Island | DZ3 | 38.0 | -45.77637 | 166.6087 | -45 46.5820000000022 | 166 36.5230000000195 |
| LI06 | S17_R06 | Long Island | DZ3 | 69.0 | -45.77782 | 166.6129 | -45 46.6690000000022 | 166 36.7710000000002 |
| CL01 | S18_R01 | Curlew Island | DZ3 | 38.7 | -45.78558 | 166.6075 | -45 47.1349999999982 | 166 36.4510000000203 |
| CL02 | S18_R02 | Curlew Island | DZ3 | 42.0 | -45.78937 | 166.6088 | -45 47.362000000002 | 166 36.5260000000203 |
| CL03 | S18_R03 | Curlew Island | DZ3 | 38.0 | -45.79812 | 166.6120 | -45 47.887000000002 | 166 36.7180000000206 |
| CL04 | S18_R04 | Curlew Island | DZ3 | 21.0 | -45.80265 | 166.5988 | -45 48.1590000000001 | 166 35.9299999999794 |
| CL05 | S18_R05 | Curlew Island | DZ3 | 33.0 | -45.80528 | 166.5881 | -45 48.3169999999979 | 166 35.2879999999791 |
| CL06 | S18_R06 | Curlew Island | DZ3 | 68.0 | -45.79398 | 166.5990 | -45 47.638999999998 | 166 35.9380000000199 |
| PH06 | S19_R06 | Pickersgill Harbour | DZ3 | 79.0 | -45.79087 | 166.6021 | -45 47.4520000000019 | 166 36.1240000000204 |
| DC01 | S20_R01 | Duck Cove | DZ3 | 25.0 | -45.74697 | 166.6567 | -45 44.8180000000022 | 166 39.4000000000213 |
| DC02 | S23_R04 | Duck Cove | DZ3 | 46.0 | -45.74255 | 166.6531 | -45 44.5529999999999 | 166 39.1879999999791 |
| DC03 | S23_R05 | Duck Cove | DZ3 | 17.0 | -45.74692 | 166.6521 | -45 44.8150000000018 | 166 39.1230000000001 |
| DC04 | S23_R06 | Duck Cove | DZ3 | 45.0 | -45.74880 | 166.6580 | -45 44.9280000000004 | 166 39.4819999999813 |
| BW01 | S24_R01 | Bowen Channel | DZ3 | 32.8 | -45.73972 | 166.6971 | -45 44.3830000000021 | 166 41.8260000000009 |
| BW02 | S24_R02 | Bowen Channel | DZ3 | 53.0 | -45.73017 | 166.7091 | -45 43.810000000002 | 166 42.5440000000216 |
| BW03 | S24_R03 | Bowen Channel | DZ3 | 36.0 | -45.72955 | 166.7153 | -45 43.7730000000001 | 166 42.9180000000012 |
| BW04 | S24_R04 | Bowen Channel | DZ3 | 20.0 | -45.72763 | 166.7263 | -45 43.6579999999982 | 166 43.5760000000184 |
| BW05 | S24_R05 | Bowen Channel | DZ3 | 51.0 | -45.73610 | 166.7239 | -45 44.1659999999999 | 166 43.4320000000201 |
| BW06 | S24_R06 | Bowen Channel | DZ3 | 22.0 | -45.74022 | 166.7223 | -45 44.4130000000019 | 166 43.3379999999985 |
| SI01 | S09_R01 | Shag Island | DZ4 | 49.6 | -45.74372 | 166.7880 | -45 44.623000000002 | 166 47.2800000000008 |
| SI02 | S09_R02 | Shag Island | DZ4 | 29.0 | -45.73778 | 166.7870 | -45 44.2669999999979 | 166 47.2180000000206 |
| SI03 | S09_R03 | Shag Island | DZ4 | 24.0 | -45.73197 | 166.7870 | -45 43.9180000000022 | 166 47.2189999999808 |
| SI04 | S09_R04 | Shag Island | DZ4 | 36.0 | -45.73337 | 166.7697 | -45 44.0020000000019 | 166 46.1820000000007 |
| EC01 | S10_R01 | East Cooper Island | DZ4 | 36.4 | -45.73463 | 166.9211 | -45 44.0779999999979 | 166 55.2679999999799 |
| EC03 | S10_R03 | East Cooper Island | DZ4 | 30.0 | -45.73527 | 166.8988 | -45 44.1160000000023 | 166 53.9299999999794 |
| EC04 | S10_R04 | East Cooper Island | DZ4 | 28.0 | -45.73700 | 166.8860 | -45 44.2200000000002 | 166 53.1570000000007 |
| EC05 | S10_R05 | East Cooper Island | DZ4 | 70.0 | -45.72872 | 166.8818 | -45 43.723000000002 | 166 52.9060000000211 |
| EC06 | S10_R06 | East Cooper Island | DZ4 | 58.0 | -45.72575 | 166.8994 | -45 43.5449999999997 | 166 53.9620000000189 |
| SC01 | S11_R01 | Supper Cove | DZ4 | 25.4 | -45.70307 | 166.9534 | -45 42.1840000000021 | 166 57.2020000000193 |
| SC02 | S11_R02 | Supper Cove | DZ4 | 55.0 | -45.70700 | 166.9553 | -45 42.4200000000002 | 166 57.3179999999993 |
| SC03 | S11_R03 | Supper Cove | DZ4 | 64.0 | -45.71162 | 166.9528 | -45 42.6970000000021 | 166 57.1679999999993 |
| SC04 | S11_R04 | Supper Cove | DZ4 | 65.0 | -45.70937 | 166.9479 | -45 42.562000000002 | 166 56.8769999999999 |
| SC05 | S11_R05 | Supper Cove | DZ4 | 54.0 | -45.70732 | 166.9435 | -45 42.4390000000019 | 166 56.6119999999801 |
| SC06 | S11_R06 | Supper Cove | DZ4 | 23.0 | -45.70253 | 166.9462 | -45 42.151999999998 | 166 56.7730000000195 |
| SH01 | S12_R01 | Shark Cove | DZ4 | 71.4 | -45.72023 | 166.9660 | -45 43.213999999998 | 166 57.9589999999812 |
| SH02 | S12_R02 | Shark Cove | DZ4 | 51.0 | -45.71955 | 166.9714 | -45 43.1730000000001 | 166 58.2839999999987 |
| SH03 | S12_R03 | Shark Cove | DZ4 | 28.0 | -45.71705 | 166.9761 | -45 43.0230000000001 | 166 58.5670000000197 |
| SH04 | S12_R04 | Shark Cove | DZ4 | 33.0 | -45.72855 | 166.9508 | -45 43.713 | 166 57.0499999999806 |
| SH05 | S12_R05 | Shark Cove | DZ4 | 51.0 | -45.73150 | 166.9468 | -45 43.8899999999999 | 166 56.8079999999997 |
| SH06 | S12_R06 | Shark Cove | DZ4 | 32.0 | -45.72108 | 166.9484 | -45 43.264999999998 | 166 56.9020000000193 |
| FB01 | S13_R01 | Cooper Island | DZ4 | 27.0 | -45.73793 | 166.8813 | -45 44.275999999998 | 166 52.8809999999998 |
| FB02 | S13_R02 | Cooper Island | DZ4 | 45.0 | -45.74085 | 166.8779 | -45 44.451 | 166 52.6729999999787 |
| FB03 | S13_R03 | Cooper Island | DZ4 | 52.0 | -45.74118 | 166.8691 | -45 44.4709999999977 | 166 52.1479999999807 |
| FB04 | S13_R04 | Cooper Island | DZ4 | 27.0 | -45.75247 | 166.8626 | -45 45.148000000002 | 166 51.7570000000201 |
| FB05 | S13_R05 | Fanny Bay | DZ4 | 62.0 | -45.76213 | 166.8347 | -45 45.7279999999979 | 166 50.0830000000191 |
| FB06 | S13_R06 | Fanny Bay | DZ4 | 71.0 | -45.77178 | 166.8419 | -45 46.3069999999983 | 166 50.5140000000014 |
| NC01 | S14_R01 | North Cooper Island | DZ4 | 55.0 | -45.71055 | 166.8425 | -45 42.6329999999997 | 166 50.5470000000011 |
| NC02 | S14_R02 | North Cooper Island | DZ4 | 32.0 | -45.70575 | 166.8288 | -45 42.3450000000002 | 166 49.7290000000192 |
| NC03 | S14_R03 | North Cooper Island | DZ4 | 85.0 | -45.71613 | 166.7994 | -45 42.9679999999983 | 166 47.9629999999791 |
| NC04 | S14_R04 | North Cooper Island | DZ4 | 18.0 | -45.71837 | 166.7825 | -45 43.1020000000019 | 166 46.9519999999786 |
| NC05 | S14_R05 | North Cooper Island | DZ4 | 28.0 | -45.72338 | 166.7607 | -45 43.4029999999979 | 166 45.6400000000198 |
| NC06 | S14_R06 | North Cooper Island | DZ4 | 18.0 | -45.72658 | 166.7987 | -45 43.5949999999983 | 166 47.9239999999797 |
| SI07 | S15_R01 | Shag Island | DZ4 | 42.1 | -45.72988 | 166.7899 | -45 43.7929999999978 | 166 47.3940000000002 |
| SI08 | S15_R02 | Shag Island | DZ4 | 36.0 | -45.73352 | 166.7811 | -45 44.011000000002 | 166 46.8690000000002 |
| SI09 | S15_R03 | Shag Island | DZ4 | 46.0 | -45.73128 | 166.7773 | -45 43.876999999998 | 166 46.6369999999801 |
| SI10 | S15_R04 | Shag Island | DZ4 | 15.0 | -45.73295 | 166.7671 | -45 43.9769999999999 | 166 46.025999999999 |
# fld24_toprint |> write_csv(file = "data/fld24_toprint.csv")First mapviews
mapview(fld24)map_fiordland24 <- fld24 |>
mutate(Depth = -Depth) |>
mapview(zcol="Depth", layer.name = "BRUV drops (Depth)") +
mapview(mr_fiordland |>
filter(Name %in% c(
"Moana Uta (Wet Jacket Arm) Marine Reserve",
"Taumoana (Five Finger Peninsula) Marine Reserve"
)),
layer.name = "Marine Reserves",
col.region = "yellow")
map_fiordland24saveRDS( map_fiordland24, "maps/map_fiordland24.rds")
mapshot(map_fiordland24, url = "maps/map_fiordland24.html")nrow(fld24)[1] 136
fld24 |>
group_by(Quality) |>
summarise(n = n())Simple feature collection with 2 features and 2 fields
Geometry type: MULTIPOINT
Dimension: XY
Bounding box: xmin: 166.4598 ymin: -45.80528 xmax: 166.9761 ymax: -45.68888
Geodetic CRS: WGS 84
# A tibble: 2 × 3
Quality n geometry
<chr> <int> <MULTIPOINT [°]>
1 Good 120 ((166.5305 -45.68888), (166.524 -45.69353), (166.5012 -45.70938…
2 OK 16 ((166.465 -45.73392), (166.4979 -45.71433), (166.6521 -45.74692…
fld24 |>
group_by(`Repeat site from 2021`) |>
summarise(n = n())Simple feature collection with 2 features and 2 fields
Geometry type: MULTIPOINT
Dimension: XY
Bounding box: xmin: 166.4598 ymin: -45.80528 xmax: 166.9761 ymax: -45.68888
Geodetic CRS: WGS 84
# A tibble: 2 × 3
`Repeat site from 2021` n geometry
<chr> <int> <MULTIPOINT [°]>
1 No 112 ((166.5305 -45.68888), (166.524 -45.69353), (16…
2 Yes 24 ((166.5152 -45.77767), (166.5058 -45.77522), (1…
fld24 |>
filter(Quality != "BAD") |>
summarise(
min = min(Depth),
max = max(Depth),
mean = mean(Depth),
median = median(Depth)
)Simple feature collection with 1 feature and 4 fields
Geometry type: MULTIPOINT
Dimension: XY
Bounding box: xmin: 166.4598 ymin: -45.80528 xmax: 166.9761 ymax: -45.68888
Geodetic CRS: WGS 84
# A tibble: 1 × 5
min max mean median geometry
<dbl> <dbl> <dbl> <dbl> <MULTIPOINT [°]>
1 14.2 86 40.8 36 ((166.5305 -45.68888), (166.524 -45.69353), (166.501…
Calculate areas
strata_clipped <- strata |>
st_transform(2193) |>
st_difference( nztm |> st_union() ) Warning: attribute variables are assumed to be spatially constant throughout
all geometries
plot(strata_clipped)strata_areas <- strata_clipped |>
mutate( Area = ( strata |> st_area() / 1e6 ) |> units::drop_units()) |>
select(Name, Area) |>
st_drop_geometry()st_as_s2(): dropping Z and/or M coordinate
strata_samples <- fld24 |>
filter(Quality != "Bad") |>
group_by(Name) |>
summarise(n = n()) |>
st_drop_geometry() |>
left_join(strata_areas) |>
mutate(
Area = round(Area, 1),
Sites_per_area = round(n / Area, 3)
) Joining with `by = join_by(Name)`
strata_samples# A tibble: 5 × 4
Name n Area Sites_per_area
<chr> <int> <dbl> <dbl>
1 DR2 14 23.2 0.603
2 DZ1 22 57.5 0.383
3 DZ2 32 54.8 0.584
4 DZ3 31 74.1 0.418
5 DZ4 37 76.1 0.486
kable(strata_samples)| Name | n | Area | Sites_per_area |
|---|---|---|---|
| DR2 | 14 | 23.2 | 0.603 |
| DZ1 | 22 | 57.5 | 0.383 |
| DZ2 | 32 | 54.8 | 0.584 |
| DZ3 | 31 | 74.1 | 0.418 |
| DZ4 | 37 | 76.1 | 0.486 |
fld24 |> filter(Quality != "Bad") |> ggplot() + aes(x=Depth) + geom_histogram() `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
fld24 |>
filter(Quality != "Bad") |>
ggplot() + aes(x=Depth) + geom_histogram() + facet_wrap(vars(Name))`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Depths
fld24 |>
ggplot() +
aes(x = `Depth sounder`, y = `Depth sensor`) +
geom_point() +
geom_abline(slope=1, intercept = 0)Warning: Removed 24 rows containing missing values or values outside the scale range
(`geom_point()`).
Mappy map map
bathy_tamatea <- readRDS("data/bathy_tamatea.rds")lim_tamatea_nzmg <- ext( c(2000000, 2042000, 5464000, 5488000) )Points and strata 2024
ggmap_fld24_strata <- ggplot() +
geom_spatraster(data = bathy_tamatea) +
scale_fill_hypso_c(name = "Depth (m)", palette="colombia_bathy") +
new_scale_fill() +
geom_sf(
data = strata |>
filter(Name %in% dstrat),
aes(fill = Name),
colour = 'black',
alpha = .5
) +
geom_sf(data = nztm, fill='grey40', colour=NA) +
geom_sf(data = fld24, size = 2, color = "black") +
geom_sf_text(
data = strata |>
filter(Name %in% dstrat),
aes(label = Name),
colour = "white",
nudge_y = c(-1500,0,0,0,0)) + # Label strata
scale_fill_brewer(name = "Stratum", palette = "Set2") +
# scale_fill_viridis_d(name = "Stratum", option = "C", alpha = 0.7) +
scale_x_continuous(limits = lim_tamatea_nzmg[1:2],
expand = c(0, 0)) +
scale_y_continuous(limits = lim_tamatea_nzmg[3:4],
expand = c(0, 0)) +
annotation_scale(location = "br") +
annotate("text", label = "Sea Through Science Ltd.") +
xlab("") + ylab("")<SpatRaster> resampled to 500760 cells.
ggmap_fld24_strataggmap_fld24_strata +
annotation_custom(mark, xmin = 2031500, xmax = 2042000, ymin = 5464000, ymax = 5470000)ggsave("maps/map_fld24_strata.png", width = 10, height = 6, dpi = 300)Strata with Breaksea too
get bbox
strata_nzmg <- strata |>
st_transform(strata, crs = 27200)
bbox_strata <- strata_nzmg |>
st_bbox()
bbox_strata xmin ymin xmax ymax
1995923 5464579 2042666 5507907
ggmap_allstrata <- ggplot() +
# geom_spatraster(data = bathy_tamatea, alpha = 0.1) +
#
# scale_fill_hypso_c(name = "Depth (m)", palette="colombia_bathy") +
# new_scale_fill() +
geom_sf(
data = strata_nzmg |>
st_transform(strata, crs = 27200),
aes(fill = Name),
colour = 'black',
alpha = .5
) +
geom_sf(data = nztm, fill='grey40', colour=NA) +
geom_sf(data = fld24, size = 2, color = "black", alpha = .5) +
geom_sf_text(
data = strata,
aes(label = Name),
colour = "black",
fontface = "bold",
nudge_y = c(0,0,0,500,-1500,0,0,0,0,0,0,0,0)
) + # Label strata
# scale_fill_brewer(name = "Stratum", palette = "Set2") +
scale_x_continuous(limits = c(bbox_strata["xmin"], bbox_strata["xmax"]),
expand = c(0, 0)) +
scale_y_continuous(limits = c(bbox_strata["ymin"], bbox_strata["ymax"]),
expand = c(0, 0)) +
annotation_scale(location = "br") +
annotate("text", label = "Sea Through Science Ltd.") +
xlab("") + ylab("") +
theme(legend.position = "none")
ggmap_allstrataggmap_allstrata +
annotation_custom(mark, xmin = 2031500, xmax = 2042000, ymin = 5464000, ymax = 5470000)ggsave("maps/map_allstrata.png", width = 8, height = 8, dpi = 300)
ggsave("maps/map_allstrata.pdf", width = 8, height = 8)Labelled map of 2024 sites
ggmap_fld24_labels <-
ggmap_fld24_strata +
geom_label_repel(
data = fld24, # |>
# mutate(
# X = st_coordinates(fld24)[,1],
# Y = st_coordinates(fld24)[,2]
# ),
aes(label = SiteID, geometry = geometry),
stat = "sf_coordinates",
# size = 1,
max.overlaps = 12,
alpha = 0.6,
box.padding = 0.05,
point.padding = 0.05,
min.segment.length = 0)
ggmap_fld24_labelsggmap_fld24_labels +
annotation_custom(mark, xmin = 2031500, xmax = 2042000, ymin = 5464000, ymax = 5470000)ggsave("maps/map_fld24_labels.png", width = 18, height = 13, dpi = 300)
ggsave("maps/map_fld24_labels.pdf", width = 18, height = 13)Points and reserves
ggmap_fld24 <- ggplot() +
geom_spatraster(data = bathy_tamatea) +
geom_sf(
data = mr_fiordland,
fill = "yellow", col = NA, alpha = .3
) +
geom_sf(data = nztm, fill='grey40', colour=NA) +
geom_sf(
data = fld24,
size = 2
) +
scale_fill_hypso_c(name = "Depth (m)", palette="colombia_bathy") +
new_scale_fill() +
scale_x_continuous(limits = lim_tamatea_nzmg[1:2],
expand = c(0, 0)) +
scale_y_continuous(limits = lim_tamatea_nzmg[3:4],
expand = c(0, 0)) +
annotation_scale(location = "br") +
annotate("text", label = "Sea Through Science Ltd.")<SpatRaster> resampled to 500760 cells.
ggmap_fld24ggmap_fld24 +
annotation_custom(mark, xmin = 2031500, xmax = 2042000, ymin = 5464000, ymax = 5470000)ggsave("maps/map_fld24.png", width = 10, height = 6, dpi = 300)